<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>确认订单</title>
	<%@ include file="../common/common.jsp"%>
	<link rel="stylesheet" type="text/css" href="${ctx}/page/lib/other/css/main.css" />
	<link rel="stylesheet" href="${ctx}/page/product/css/confirmProductOrder.css?v=${version}"/>
	<link rel="stylesheet" type="text/css" href="${ctx}/page/lib/tinyalert/css/zepto.alert.css">
	<script type="text/javascript" src="${ctx}/page/lib/tinyalert/js/zepto.alert.js"></script>
</head>
<body>
<div class="bg-silver" style="height:5px;"></div>
<div class="bg-white">
	<div class="line padding-small border-bottom">
		<div class="xs3 text-center">订&nbsp;&nbsp;单&nbsp;&nbsp;号:</div>
		<div class="xs9">${order.orderNo}</div>
	</div>
	<div class="line padding-small border-bottom">
		<div class="xs3 text-center">商品名称:</div>
		<div class="xs9">${order.name}</div>
	</div>
	<div class="line padding-small border-bottom">
		<div class="xs3 text-center">规&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;格:</div>
		<div class="xs9">${order.skuName}</div>
	</div>
	<div class="line padding-small border-bottom">
		<div class="xs3 text-center">商品数量:</div>
		<div class="xs9">${order.counts}</div>
	</div>
	<div class="line padding-small border-bottom">
		<div class="xs3 text-center">商品金额:</div>
		<div class="xs9"><fmt:formatNumber type="number" value="${order.productAmount}" pattern="0.00" maxFractionDigits="2"/>&nbsp;贝币</div>
	</div>
	<div class="line padding-small border-bottom">
		<div class="xs3 text-center">运&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;费:</div>
		<div class="xs9"><fmt:formatNumber type="number" value="${order.freightAmount}" pattern="0.00" maxFractionDigits="2"/>&nbsp;贝币</div>
	</div>
	<div class="line padding-small border-bottom">
		<div class="xs3 text-center">支付金额:</div>
		<div class="xs9 text-red"><fmt:formatNumber type="number" value="${order.payAmount}" pattern="0.00" maxFractionDigits="2"/>&nbsp;贝币</div>
	</div>
	<div class="line padding-small border-bottom">
		<div class="xs3 text-center">赠送积分:</div>
		<div class="xs9 text-red"><fmt:formatNumber type="number" value="${order.givePoint}" pattern="0.0000" maxFractionDigits="4"/>&nbsp;积分</div>
	</div>
	<div class="bg-silver" style="height:10px;"></div>
	<div class="line padding-small border-bottom border-top">
			<div class="xs3 text-center">收&nbsp;&nbsp;货&nbsp;&nbsp;人:</div>
			<div class="xs9">${order.receiveName}</div>
	</div>
	<div class="line padding-small border-bottom">
			<div class="xs3 text-center">手&nbsp;&nbsp;机&nbsp;&nbsp;号:</div>
			<div class="xs9">${order.receiveMobile}</div>
	</div>
	<div class="line padding-small border-bottom">
			<div class="xs3 text-center">收货地址:</div>
			<div class="xs9">${order.receiveAddress}</div>
	</div>
	<div class="line padding-small border-bottom">
			<div class="xs3 text-center">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:</div>
			<div class="xs9">${order.remark}</div>
	</div>
</div>
<div class="bg-silver" style="height:10px;"></div>
<div class="margin">
		您的贝币余额:<span class="text-red"><fmt:formatNumber type="number" value="${jbalance}" pattern="0.0000" maxFractionDigits="4"/></span>
		&nbsp;<span class="text-center text-small">贝币余额不足？<a class="text-red" href="http://mp.weixin.qq.com/s/Gkl3eoDu069HEHGWSj20uA">->点击获取<-</a></span>
</div>
<div class="margin">
	<button id="beiBiPay" class="sureBtn">贝币支付</button>
</div>
<div class="margin">
	
</div>
<input id="orderNo" type="hidden" value="${order.orderNo}">
<script type="text/javascript">
	var flag = true;
	$(document).ready(function(){
		var orderNo = $("#orderNo").val();
		$('#beiBiPay').on('click', function() {
		    $.dialog({
		        content : '确定支付吗？',
		        title : 'ok',
		        ok : function() {
		            //alert('我是确定按钮，回调函数返回false时不会关闭对话框。');
		            gopay(orderNo);
		            //return false;
		        },
		        cancel : function() {
		           // alert('我是取消按钮');
		        },
		        lock : false
		    });
		});
	});

	function gopay(orderNo){
		if(flag){
			flag = false;
			var dialog = $.dialog({
		        content : '支付中,请稍后...'
		    });
			$.ajax({
				type : 'POST',
				url : ctx + '/page/beiBiPay.do',
				data : {
					orderNo : orderNo
				},
				dataType : 'json',
				timeout : 30000,
				context : $('body'),
				success : function(data) {
					dialog.close();
					if (data.code == "ok") {
						flag = true;
						window.location.href=mServerUrl+"/page/paySuccess.htm?time="+((new Date()).getTime());
					} else {
						flag = true;
					    $.dialog({
					        content : data.msg,
					        title: "alert",
					        time : 2000
					    });
					}
				},
				error : function(xhr, type) {
					dialog.close();
					flag = true;
					//alert('提交失败!');
				    $.dialog({
				        content : '提交失败!',
				        title: "alert",
				        time : 2000
				    });
				}
		});
	}
}
</script>
</body>
</html>